<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>history</title>
  </head>
  <body>
    <button class="back">←后退</button>
    <button class="forward">前进→</button>

    <script>
        // 1.前进
        const forward = document.querySelector('.forward')
        forward.addEventListener('click',function(){
            // history.forward()
            history.go(1)
        })

        // 2.后退
        const back = document.querySelector('.back')
        forward.addEventListener('click',function(){
            // history.back()
            history.go(-1)

        })
    </script>
  </body>
</html>
